package cn.byapps.attendance.service.impl;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import cn.byapps.attendance.dao.StudentDao;
import cn.byapps.attendance.dao.TeacherDao;
import cn.byapps.attendance.entity.Student;
import cn.byapps.attendance.entity.Teacher;
import cn.byapps.attendance.service.LoginService;

@Service
@Transactional
public class LoginServiceImpl implements LoginService {

	@Resource
	private StudentDao personDao;
	@Resource
	private TeacherDao teacherDao;

	@Override
	public Student getLoginStudent(Student p) {
		return personDao.get(p.getId());
	}

	@Override
	public Object getLoginObject(String id, String password) {
		Teacher t = teacherDao.get(id);

		if (t != null ) {
			return t;
		}
		Student s = personDao.get(id);
		if (s != null ) {
			return s;
		}
		return null;
	}

}
